// std::sort(str2.begin(), str2.end(), [](const char& a, const char& b) {return
// a < b;}  ); std::count_if(vecWord.begin(), vecWord.end(), [&otherWord](const
// std::string &s) { return s == otherWord;} );  //
// s代表vector<string>中的元素string

// 6   cab ad abcd cba abc bca    abc    1按字典序排列后的第 k 个单词
// 3
// bca

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

std::string toOrderString(const std::string& str) {
  std::string str2 = str;
  std::sort(str2.begin(), str2.end(),
            [](const char& a, const char& b) { return a < b; });
  return str2;
}

bool isBrother(std::string strA, std::string strB) {
  if (strA.length() != strB.length() || strA == strB) {
    return false;
  }
  std::sort(strA.begin(), strA.end());
  std::sort(strB.begin(), strB.end());
  if (strA == strB) {
    return true;
  }
  return false;
}

int main() {
  int nWordCnt = 6;
  std::vector<std::string> vecWord = {"cab", "ad", "abcd", "cba", "abc", "bca"};
  std::vector<std::string> vecWord_2;
  std::string rawWord = "abc";
  std::string rawWord_2;
  int index = 1;

  std::cin >> nWordCnt;
  vecWord.clear();
  for (int i = 0; i < nWordCnt; i++) {
    std::string s;
    std::cin >> s;
    vecWord.push_back(s);
  }
  std::cin >> rawWord;
  std::cin >> index;

  int count = 0;
  for (int i = 0; i < nWordCnt; i++) {
    if (isBrother(rawWord, vecWord.at(i))) {
      count++;
      vecWord_2.push_back(vecWord.at(i));
    }
  }
  printf("%d\n", count);
  std::sort(vecWord_2.begin(), vecWord_2.end());
  // for(auto s : vecWord_2){printf("%s, ", s.c_str());}printf("\n");
  if (index <= vecWord_2.size()) {
    printf("%s\n", vecWord_2.at(index - 1).c_str());
  }
  return 0;
}
